using System;
using System.Collections.Generic;
using System.Text;
using Barrage.Render;
using Barrage;
using Barrage.Scenes;
using Barrage.GUI;
using Barrage.GUI.Elements;

namespace Spacedash.Game.Subgames
{
    sealed class MainMenuElements
    {
        public const string StartButton = "START_BUTTON";
        public const string ConfigButton = "CONFIG_BUTTON";
        public const string ProfilesButton = "PROFILES_BUTTON";
        public const string CreditsButton = "CREDITS_BUTTON";
        public const string ExitButton = "EXIT_BUTTON";
    }
    class MainMenuSection : GUISection
    {
        public override int Id
        {
            get { return (int)GameState.MainMenu; }
        }
        public MainMenuSection(SpacedashGame parent)
            : base("MainMenu", parent)
        {
            RegisterButtonEvent(MainMenuElements.ProfilesButton, new GUIButtonHandler(ProfilesButtonClick));
            RegisterButtonEvent(MainMenuElements.StartButton, new GUIButtonHandler(StartButtonClick));
            RegisterButtonEvent(MainMenuElements.ConfigButton, new GUIButtonHandler(ConfigButtonClick));
            RegisterButtonEvent(MainMenuElements.CreditsButton, new GUIButtonHandler(CreditsButtonClick));
            RegisterButtonEvent(MainMenuElements.ExitButton, new GUIButtonHandler(ExitButtonClick));
        }


        public void StartButtonClick(string buttonId)
        {
            Parent.NextGameSectionId = (int)GameState.NewGameMenu;
        }

        public void ConfigButtonClick(string buttonId)
        {
            Parent.NextGameSectionId = (int)GameState.Configuration;
        }
        public void ExitButtonClick(string buttonId)
        {
            ((SpacedashGame)Parent).FinishGame();
        }

        public void ProfilesButtonClick(string buttonId)
        {
            Parent.NextGameSectionId = (int)GameState.Profiles;
        }

        public void CreditsButtonClick(string buttonId)
        {
            Parent.NextGameSectionId = (int)GameState.Credits;
        }

        public override void Dispose()
        {
            UnRegisterButtonEvent(MainMenuElements.ProfilesButton, new GUIButtonHandler(ProfilesButtonClick));
            UnRegisterButtonEvent(MainMenuElements.StartButton, new GUIButtonHandler(StartButtonClick));
            UnRegisterButtonEvent(MainMenuElements.ConfigButton, new GUIButtonHandler(ConfigButtonClick));
            UnRegisterButtonEvent(MainMenuElements.ExitButton, new GUIButtonHandler(ExitButtonClick)); 
            base.Dispose();
        }

    }
}
